from django.contrib import admin
from .models import HomeCarousel, PrimaryClassification, SecondaryClassification, HotSearchKeyword
# Register your models here.

# 首页轮播图
class HomeCarouselAdmin(admin.ModelAdmin):
  list_display = ('name', 'link_url', 'is_show', 'car_img',)

# 一级分类
class PrimaryClassificationAdmin(admin.ModelAdmin):
  list_display = ('name', 'is_show', 'category_ico', 'created_time', 'updated_time',)

# 二级分类
class SecondaryClassificationAdmin(admin.ModelAdmin):
  def _show_upper_level(self, obj):
    return obj.upper_level.name
  _show_upper_level.short_description = "所属分类"
  list_display = ('name', '_show_upper_level', 'is_show', 'created_time', 'updated_time',)


# 热门搜索
class HotSearchKeywordAdmin(admin.ModelAdmin):
  list_display = ('name', 'is_show',)
# 注册后台
admin.site.register(HomeCarousel, HomeCarouselAdmin)
admin.site.register(PrimaryClassification, PrimaryClassificationAdmin)
admin.site.register(SecondaryClassification, SecondaryClassificationAdmin)
admin.site.register(HotSearchKeyword, HotSearchKeywordAdmin)